/**
 * @title 更新缓存
 * @author start2004
 * @since 2024-08-14
 *
 * @param  {string} key 键值
 * @param {mixed} value 缓存数据
 * @return {null}
 */
async function SetStorage(key, value) {
    await chrome.storage.local.set({ [key]: value });
}

/**
 * @title 获取缓存
 * @author start2004
 * @since 2024-08-14
 *
 * @param {string} key 缓存键值
 * @return {mixed} 键值对应数据
 */
async function GetStorage(key) {
    const result = await chrome.storage.local.get(key);

    /**
     * @return
     */
    return result[key];
}

/**
 * @title 删除缓存数据
 * @author start2004
 * @since 2024-09-23
 *
 * @param {string} key 缓存键值
 * @return {null}
 */
async function RemoveStorage(key) {
    await chrome.storage.local.remove(key);
}

/**
 * @title 获取请求页码
 * @author start2004
 * @since 2025-03-06
 */
async function GetRequestPage(){
    let requestPage = await GetStorage("request_page");
    if(requestPage === undefined) {
        requestPage = {
            start: 0,
            now: 0,
            end: 0,
            nickname: ""
        };
    } else {}
    // console.log(requestPage);

    return requestPage;
}